/*
 * surfor_data.cpp
 *
 *  Created on: 2009. 5. 15
 *      Author: neogeo94
 */

#include "surfor_data.h"

void PrintSurforData(CEntities* pEntities){
	CEntities* Entities;
	Entities=pEntities;

	int totalNumVertex;
	totalNumVertex=0;

	CPolyline* tempPL;
	CVertex* tempVT;

	tempPL=Entities->Polylines;

	while(tempPL!=NULL) {
		totalNumVertex=totalNumVertex+tempPL->vertexCount;
		tempPL=tempPL->next;
	}

	std::string fileName;
	fileName="surfor.data";

	std::ofstream outputFile;
	outputFile.open(fileName.c_str());

	outputFile<<"Converted SURFOR data file."<<std::endl;
	outputFile<<totalNumVertex+Entities->polylineCount<<std::endl;

	tempPL=Entities->Polylines;
	while (tempPL!=NULL) {
		tempVT=tempPL->Vertexs;
		while (tempVT!=NULL) {
			outputFile<<tempVT->x<<", "<<tempVT->y<<std::endl;
			tempVT=tempVT->next;
		}
		outputFile<<"999999.0, 999999.0"<<std::endl;
		tempPL=tempPL->next;
	}

	outputFile.close();
}
